package com.huahua.interceptor.handler;

import com.huahua.enums.ExceptionEnum;
import com.huahua.annotation.Authority;
import com.huahua.entity.User;
import com.huahua.exception.BusinessException;

/**
 * 不允许操作类型的handler
 *
 * @author huahua
 */
public class AuthorityTypeHandler extends AbstractAuthorityHandler{
    @Override
    void processHandler(User user, Authority authority) {
        if (authority.type() > user.getAuthority()) {
            throw new BusinessException(ExceptionEnum.FORBIDDEN.getCode(),
                    ExceptionEnum.FORBIDDEN.getMsg(), "不允许的操作类型");
        }
    }
}
